<?php

namespace app\models;

use Yii;
use app\components\behaviors\CreatorBehaviors;
use yii\web\UploadedFile;



/**
 * This is the model class for table "kd_user".
 *
 * @property integer $gl_id
 * @property string $gl_username
 * @property string $gl_passwors
 * @property integer $quanxian
 * @property integer $yey_id
 * @property integer $bj_id
 * @property integer $mobile
 * @property string $addtime
 * @property string $update_time
 * @property string $update_people
 * @property string $guard_status
 */
class Users extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'kd_user';
    }

    public function behaviors()
    {
        return [
            [
                'class'=>CreatorBehaviors::className(),
                'fieldName'=>'update_people',
            ],
            [
                'class' => \app\components\behaviors\DatetimeBehavior::className(),
                'createDate' => 'addtime',
                'updateDate' => 'update_time',

            ],
            [
                'class' => \app\components\behaviors\LogBehavior::className(),
                'tableName' => '用户',
                'attributeValue' => 'gl_username',
            ],
            [
                'class' => \app\components\behaviors\PasswordBehavior::className(),
                'password'=>'gl_passwors'
            ],
            [
                'class'=>\app\components\behaviors\RecoverBehavior::className(),
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [

            [['gl_username', 'gl_passwors', 'quanxian', 'yey_id', ], 'required'],
            [['quanxian', 'yey_id', 'bj_id','guard_status','mobile'], 'integer'],
            [['addtime', 'update_time','entry_time','off_time','sex','age','bj_num'], 'safe'],

            [['email'],'email'],
            [['gl_username', 'gl_passwors', 'update_people','touxiang','email'], 'string', 'max' => 50],

           [['mobile'],"match",'pattern'=>'/^1[3|4|5|7|8][0-9]\d{8}$/','message'=>'手机号格式不正确'],

            ['mobile', 'unique', 'targetClass' => '\app\models\Users', 'message' => '手机号已被使用'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'gl_id' => '管理用户id',
            'gl_username' => '用户名',
            'gl_passwors' => '密码',
            'quanxian' => '权限',
            'yey_id' => '所属幼儿园id',
            'bj_id' => '所属幼儿园班级id',

            'sex' => '性别',
            'age' => '年龄',
            'bj_num' => '班级人数',

            'addtime' => '添加时间',
            'update_time' => '最后修改时间',
            'update_people' => '修改人',
            'guard_status' => '岗位状态',
            'mobile' => '手机',
            'eamil' => '邮箱',
            'touxiang' => '头像',
            'entry_time'=>'入职时间',
            'off_time'=>'离职时间',
        ];
    }


}


